package ProducerConsumer;

public class Producer extends Thread{
    private Warehouse warehouse;//保存数据的仓库
    public Producer(Warehouse warehouse){
        this.warehouse=warehouse;
    }

    @Override
    public void run() {
        for(int i=1;i<=10;i++){
            warehouse.put(i);//调用仓库的put方法，将数据i放入仓库
            System.out.println("Producer put:"+i);
            try{
                sleep(100);
            }catch (InterruptedException e){}
        }
    }
}
